﻿<?xml version="1.0" encoding="utf-8"?>
<UserControl
    x:Class="Automator.StartPage.StartPageContent" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:linq="clr-namespace:System.Xml.Linq;assembly=System.Xml.Linq"
    xmlns:classes="clr-namespace:Automator.Classes"
    Background="{x:Static SystemColors.WindowBrush}">
    <UserControl.Resources>
        <ResourceDictionary>
            <classes:RssDescriptionConverter
                x:Key="RssDescriptionConverter" />
            <DataTemplate
                x:Key="rssTemplate"
                DataType="{x:Type linq:XElement}">
                <Border
                    BorderBrush="{x:Static SystemColors.ControlDarkBrush}"
                    BorderThickness="1"
                    x:Name="itemBorder"
                    CornerRadius="4"
                    Margin="0,0,8,8">
                    <StackPanel
                        Orientation="Vertical"
                        Margin="4">
                        <TextBlock
                            Margin="8,6,8,0"
                            Text="{Binding XPath=title}"
                            FontSize="12"
                            FontWeight="Bold" />
                        <TextBlock
                            Margin="8,4,8,0"
                            Foreground="{x:Static SystemColors.GrayTextBrush}"
                            FontSize="10"
                            VerticalAlignment="Center"
                            Text="{Binding XPath=pubDate}" />
                        <TextBlock
                            Text="{Binding XPath=description, Converter={StaticResource RssDescriptionConverter}}"
                            TextWrapping="Wrap"
                            Margin="8,16,8,8"
                            FontSize="12" />
                    </StackPanel>
                </Border>
            </DataTemplate>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition
                Height="100" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition
                Width="300" MinWidth="200" MaxWidth="600" />
            <ColumnDefinition Width="6" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <Grid
            Grid.Row="0"
            Grid.ColumnSpan="2"></Grid>
        <GridSplitter Grid.Row="1" Grid.Column="1" Background="Transparent" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
        <DockPanel
            LastChildFill="True"
            Grid.Column="2"
            Grid.Row="1">
            <DockPanel
                DockPanel.Dock="Top"
                LastChildFill="False">
                <StackPanel
                    Orientation="Horizontal"
                    Margin="8"
                    VerticalAlignment="Center">
                    <Image
                        Width="32"
                        Height="32"
                        Margin="2"
                        Source="/Automator;component/resources/rss.png" />
                    <TextBlock
                        FontSize="14"
                        FontWeight="Bold"
                        Text="Latest News"
                        TextTrimming="CharacterEllipsis"
                        VerticalAlignment="Center"
                        Margin="4,0,0,0" />
                </StackPanel>
                <Button
                    DockPanel.Dock="Right"
                    Content="Refresh News"
                    x:Name="btnRefresh"
                    Margin="8"
                    Padding="4"
                    VerticalAlignment="Center"
                    Click="BtnRefresh_Click" />
            </DockPanel>
            <ScrollViewer
                Margin="8"
                VerticalScrollBarVisibility="Auto"
                Focusable="False"
                BorderThickness="0">
                <ItemsControl
                    x:Name="lstRss"
                    BorderThickness="0"
                    ItemTemplate="{StaticResource rssTemplate}"
                    ItemsSource="{Binding XPath=item}"
                    Focusable="False">
                    <ItemsControl.Style>
                        <Style>
                            <Style.Resources>
                                <SolidColorBrush
                                    x:Key="{x:Static SystemColors.HighlightBrushKey}"
                                    Color="Transparent" />
                                <SolidColorBrush
                                    x:Key="{x:Static SystemColors.HighlightTextBrushKey}"
                                    Color="{x:Static SystemColors.WindowTextColor}" />
                            </Style.Resources>
                        </Style>
                    </ItemsControl.Style>
                </ItemsControl>
            </ScrollViewer>
        </DockPanel>
        <DockPanel
            LastChildFill="True"
            Grid.Column="0"
            Grid.Row="1">
            <DockPanel
                DockPanel.Dock="Top"
                LastChildFill="False">
                <StackPanel
                    Orientation="Horizontal"
                    Margin="8"
                    VerticalAlignment="Center">
                    <Image
                        Width="32"
                        Height="32"
                        Margin="2"
                        Source="/Automator;component/resources/actions.png" />
                    <TextBlock
                        FontSize="14"
                        FontWeight="Bold"
                        Text="Common Actions"
                        TextTrimming="CharacterEllipsis"
                        VerticalAlignment="Center"
                        Margin="4,0,0,0" />
                </StackPanel>
            </DockPanel>
            <ScrollViewer
                VerticalScrollBarVisibility="Auto"
                Margin="8"
                Focusable="False">
                <StackPanel
                    Orientation="Vertical"
                    Focusable="False">
                    <TextBlock
                        Margin="8,8,8,4">
                        <Hyperlink
                            x:Name="lnkSqlServer">Connect To SQL Server</Hyperlink>
                    </TextBlock>
                    <TextBlock
                        Margin="8,4,8,8"
                        Text="Configure Microsoft SQL Server connection to be able to store Workflows and Solutions in a database."
                        TextWrapping="Wrap" />
                    <TextBlock
                        Margin="8,8,8,4">
                        <Hyperlink
                            x:Name="lnkNewSolution">Start New Solution</Hyperlink>
                    </TextBlock>
                    <TextBlock
                        Margin="8,4,8,8"
                        Text="Create new Automator Solution document which can contain one or several Workflows."
                        TextWrapping="Wrap" />
                    <TextBlock
                        Margin="8,8,8,4">
                        <Hyperlink
                            x:Name="lnkNewWorkflow">Create Blank Workflow</Hyperlink>
                    </TextBlock>
                    <TextBlock
                        Margin="8,4,8,8"
                        Text="Add new Workflow to the current Solution and start to add various Tasks to it."
                        TextWrapping="Wrap" />
                    <TextBlock
                        Margin="8,8,8,4">
                        <Hyperlink
                            x:Name="lnkOpenSolution">Open Existing Solution</Hyperlink>
                    </TextBlock>
                    <TextBlock
                        Margin="8,4,8,8"
                        Text="Load previously saved Solution file to continue your work."
                        TextWrapping="Wrap" />
                    <TextBlock
                        Margin="8,8,8,4">
                        <Hyperlink
                            x:Name="lnkOpenWorkflow">Open Existing Workflow</Hyperlink>
                    </TextBlock>
                    <TextBlock
                        Margin="8,4,8,8"
                        Text="Add previously saved Workflow to the current Solution."
                        TextWrapping="Wrap" />
                    <TextBlock
                        Margin="8,8,8,4">
                        <Hyperlink
                            x:Name="lnkDocumentation">Online Documentation</Hyperlink>
                    </TextBlock>
                    <TextBlock
                        Margin="8,4,8,8"
                        Text="Read online tutorials and examples that explain how to work with Automator."
                        TextWrapping="Wrap" />
                </StackPanel>
            </ScrollViewer>
        </DockPanel>
    </Grid>
</UserControl>